package com.ssm.hj.controller;

import com.github.pagehelper.PageInfo;
import com.ssm.hj.page.Page;
import com.ssm.hj.search.UserSearch;
import com.ssm.hj.service.UserService;
import com.ssm.pojo.User;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
public class UserController {
    @Resource
    private UserService userService;
    //登入查询
    @RequestMapping("/hj/loginQuery")
    public User loginQuery(String name, String password, HttpServletRequest request) throws Exception {
        return this.userService.loginQuery(name,password,request);
    }
    //查询所有用户
    @RequestMapping("/hj/queryUserAll")
    public PageInfo<User> queryUserAll(@RequestBody Page<UserSearch> page) throws Exception {
        return this.userService.searchQueryUserAllService(page);
    }
    //修改用户状态
    @RequestMapping("/hj/updateUserState")
    public int updateState(int id,int state) throws Exception {
        return this.userService.updateStateService(id,state);
    }
}
